import React, { Component } from 'react'
import { Select } from 'antd'

import { getChannelsAPI } from 'api/content'
const { Option } = Select
export default class ArtChannel extends Component {
  state = {
    channels: [],
    currency: '',
  }
  componentDidMount() {
    this.getChannels()
  }

  // 获取频道列表
  getChannels = async () => {
    const {
      data: { channels },
    } = await getChannelsAPI()
    this.setState({ channels })
  }

  render() {
    const { channels } = this.state
    const { value, onChange } = this.props
    return (
      <Select
        value={value}
        onChange={onChange}
        placeholder="请选择频道"
        style={{ width: 300 }}
        allowClear
      >
        {channels.map((item) => (
          <Option key={item.id} value={item.id}>
            {item.name}
          </Option>
        ))}
      </Select>
    )
  }
}
